﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


class BinarySearch
{
    static int BinSearch(int left, int right, int element, int[] arr)
    {
        
        int middle = (right+left) / 2;
        
        if (arr[middle] > element)
        {
            return BinSearch(left, middle, element, arr);
        }
        else if (arr[middle] < element)
        {
            return BinSearch(middle, right, element, arr);
        }

        else
        {
            return middle;
        }

    }

    static void Main()
    {
        int[] arr = { 4, 1, 2, 2, 3, 4, 8, 1, 2, 5, 4, 2, 2, 6 };
        Array.Sort(arr);
        for (int i = 0; i < arr.Length; i++)
        {
            Console.WriteLine(arr[i]);
        }
       Console.WriteLine(BinSearch(0, 13, 4, arr)) ;
    }
}

